package com.industry.system.controller;

import com.industry.framework.common.Result;
import com.industry.framework.common.page.PageQuery;
import com.industry.framework.common.page.TableDataInfo;
import com.industry.system.controller.vo.SystemCodeVo;
import com.industry.system.dal.dataobject.SystemCode;
import com.industry.system.service.SystemCodeService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author nbZhuozh
 * @Date 2025-02-14  14:08
 **/
@RestController
@RequestMapping("/system-code")
public class SystemCodeController {

    @Resource
    private SystemCodeService systemCodeService;

    @GetMapping("query-system-code-list")
    public Result<TableDataInfo<SystemCodeVo>> querySystemCodeList(PageQuery pageQuery){
        return Result.success(systemCodeService.getAllSystemCodes(pageQuery));
    }

    @GetMapping("/query-system-code-byId")
    public Result<SystemCode> querySystemCodeById(@RequestParam("codeId") String codeId){
        return Result.success(systemCodeService.querySystemCodeById(codeId));
    }

    @PostMapping("/insert")
    public Result<String> insert(@RequestBody SystemCode systemCode){
        return systemCodeService.insert(systemCode) > 0 ? Result.success("success") : Result.fail("fail");
    }


    @PostMapping("/modify")
    public Result<String> modify(@RequestBody SystemCode systemCode){
        return systemCodeService.modify(systemCode) > 0 ? Result.success("success") : Result.fail("fail");
    }


    @GetMapping("query-all-system-code")
    public Result<List<SystemCode>> queryAllSystemCode(){
        return Result.success(systemCodeService.queryAllSystemCode());
    }


}
